package com.qfmy.web.app.minio;


import com.qfmy.common.minio.MinioProperties;
import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 清风明月
 * @Package com.qfmy.common.minio
 * @date 2025/9/9
 * @descriptio  minio配置类
 */
@Configuration
@SuppressWarnings("all")
@EnableConfigurationProperties(MinioProperties.class)
@ConditionalOnProperty(name = "minio.endpoint")
public class MinoConfiguration {

    @Autowired
    private MinioProperties properties;

    /**
     * 创建minio客户端
     * @return
     */
    @Bean
    public MinioClient getClient(){
        return MinioClient.builder().endpoint(properties.getEndpoint())
                .credentials(properties.getAccessKey(), properties.getSecretKey())
                .build();
    }
}
